#include <bits/stdc++.h>
#define int long long
using namespace std;

const int MAXN = 1e5 + 5;
const double EPS = 1e-6;

int T;
int n, m, L, V;

struct Car {
	int d, v, a;
} w[MAXN];

struct Range {
	int l, r;
};

int p[MAXN];

int sqr_ins_velo(int v0, int a, int s) {
	return v0 * v0 + 2 * a * s;
}

bool cmp(Range x, Range y) {
	return (x.l == y.l) ? (x.r < y.r) : (x.l < y.l);
}

void solve() {
	cin >> n >> m >> L >> V;
	for (int i = 1; i <= n; i++) cin >> w[i].d >> w[i].v >> w[i].a;
	for (int i = 1; i <= m; i++) cin >> p[i];
	int ans1 = 0, ans2 = 0;
	vector<Range> os;
	for (int i = 1; i <= n; i++) {
		if (w[i].a < 0) {
			if (w[i].v <= V) continue;
			bool flag1 = false, flag2 = false;
			int l, r;
			for (int j = 1; j <= m; j++) {
				if (w[i].d > p[j]) continue;
				int iv = sqr_ins_velo(w[i].v, w[i].a, p[j] - w[i].d);
				if (!flag1 && iv > V * V) flag1 = true, ans1++, l = j;
				if (iv < V * V) {
					r = j - 1, flag2 = true;
					break;
				}
			}
			if (flag1) os.push_back((Range){ l, (flag2 ? r : m ) });
		}
		else {
			int l;
			bool flag = false;
			for (int j = 1; j <= m; j++) {
				if (w[i].d > p[j]) continue;
				int iv = sqr_ins_velo(w[i].v, w[i].a, p[j] - w[i].d);
				if (iv > V * V) {
					ans1++, l = j, flag = true;
					break;
				}
			}
			if (flag) os.push_back((Range){ l, m });
		}
	}
	sort(os.begin(), os.end(), cmp);
	priority_queue<int, vector<int>, greater<int>> q;
	os.push_back((Range){ m + 1, m + 1 });
	for (int i = 0; i < os.size(); i++) {
		if (!q.empty() && os[i].l > q.top()) {
			while (!q.empty()) q.pop();
			ans2++;
		}
		q.push(os[i].r);
	}
	cout << ans1 << " " << m - ans2 << endl;
}

signed main() {
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> T;
	while (T--) solve();
	return 0;
}
